package com.ltsznh.android.frequencycounter;

import android.content.Context;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

/**
 * Created by 涛 on 13-12-24.
 */
public class FrequencyView extends SurfaceView implements SurfaceHolder.Callback {
    public static TouchThread touchThread;//指南针线程

    public static Paint clearPaint = new Paint();
    private int cHeight;
    private int cWdith;

    public FrequencyView(Context context, AttributeSet attrs, int dd) {
        super(context, attrs, dd);
        init();
    }

    public FrequencyView(Context context, AttributeSet attrs) {
        super(context,attrs);
        init();
    }

    public FrequencyView(Context context) {
        super(context);
        init();
    }

    protected void init(){
        SurfaceHolder surfaceHolder = getHolder();
        surfaceHolder.addCallback(this);

        touchThread = new TouchThread(surfaceHolder);
        touchThread.start();
    }

    @Override
    public void surfaceCreated(SurfaceHolder surfaceHolder) {
        cWdith = getWidth();
        cHeight = getHeight();
        touchThread.setSize(cWdith,cHeight);

    }

    @Override
    public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) {
        touchThread.run();
    }

    @Override
    public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
    }



}
